package com.ftg.learn.xmlinterface.mapper;

import com.ftg.learn.xmlinterface.entity.CourseEntity;
import com.ftg.learn.xmlinterface.entity.StudentEntity;
import com.ftg.learn.xmlinterface.entity.TeacherEntity;
import com.ftg.learn.xmlinterface.vo.CourseVo;
import org.apache.ibatis.annotations.*;

import java.lang.reflect.Method;
import java.util.List;

/**
 * 描述     课程
 *
 * @author 布衣
 * @date 2025/5/28
 */
public interface CourseMapper {

    @Select("select * from course join teacher on course.tno = teacher.tno")
    List<CourseVo> courseList();

    /**
     * 课程下拉列表框中，老师下拉列表框当中的数据
     * @param cno 课程编号
     * @return 学生信息
     */
    @Select("select * from student where sno in (select sno from sc where cno = #{cno})")
    List<StudentEntity>chooseCourseWithStudent(String cno);

    /**
     * 添加课程时，老师下拉列表框当中的数据
     * @return
     */
    @Select("select tno,tname from teacher")
    List<TeacherEntity> addCourseWithTeacher();

    @Insert("insert into course(cno,cname,tno) values(#{cno},#{cname},#{tno})")
    int saveCourse(CourseEntity courseEntitiy);

    int updateCourse(CourseEntity courseEntitiy);

    /**
     * 删除课程
     * @param tno 编程
     * @return    条数
     */
    @Delete("delete from course where cno = #{cno}")
    int delCourseById(@Param("cno")String cno);


}
